﻿using J.Model;
using J.ProductGet.Application.Command.ClassifiedManagementCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;

namespace J.ProductGet.Controllers
{
    /// <summary>
    /// 分类管理(读)
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ClassifiedManagementController : ControllerBase
    {
        private readonly IMediator _mediator;
        public ClassifiedManagementController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 分类管理表显示带分页
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> ClassifiedManagementGet(ClassifiedManagementGetCommand command)
        {
            //return Ok(await _sqlSugarClient.Queryable<ClassifiedManagement>().ToListAsync());
            return Ok(await _mediator.Send(command));
        }
        /// <summary>
        /// 分类管理表显示
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> ManagementGet(ManagementGetCommand command)
        {
            return Ok(await _mediator.Send(command));
        }
        /// <summary>
        /// 分类管理表反填
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> ClassifiedManagementBackil(ClassifiedManagementBackilCommand command)
        {
            //return Ok(await _sqlSugarClient.Queryable<ClassifiedManagement>().Where(x => x.CategoryManagementID == CategoryManagementID).ToListAsync());int CategoryManagementID
            return Ok(await _mediator.Send(command));
        }
    }
}
